import { Ref } from 'vue';
import { VxeGridInstance } from 'vxe-table';
export default function extendTableMethods(zhGrid: Ref<VxeGridInstance>) {
	const functionList = [
		'getRefMaps',
		'getComputeMaps',
		'clearAll',
		'syncData',
		'updateData',
		'loadData',
		'reloadData',
		'reloadRow',
		'loadColumn',
		'reloadColumn',
		'getRowNode',
		'getColumnNode',
		'getRowIndex',
		'getVTRowIndex',
		'getVMRowIndex',
		'getColumnIndex',
		'getVTColumnIndex',
		'getVMColumnIndex',
		'createData',
		'createRow',
		'revertData',
		'clearData',
		'isInsertByRow',
		'isUpdateByRow',
		'getColumns',
		'getColumnById',
		'getColumnByField',
		'getTableColumn',
		'getData',
		'getCheckboxRecords',
		'getParentRow',
		'getRowSeq',
		'getRowById',
		'getRowid',
		'getTableData',
		'hideColumn',
		'showColumn',
		'resetColumn',
		'refreshColumn',
		'refreshScroll',
		'recalculate',
		'closeTooltip',
		'isAllCheckboxChecked',
		'isAllCheckboxIndeterminate',
		'getCheckboxIndeterminateRecords',
		'setCheckboxRow',
		'isCheckedByCheckboxRow',
		'isIndeterminateByCheckboxRow',
		'toggleCheckboxRow',
		'setAllCheckboxRow',
		'getRadioReserveRecord',
		'clearRadioReserve',
		'getCheckboxReserveRecords',
		// 'clearCheckboxReserve',
		'toggleAllCheckboxRow',
		// 'clearCheckboxRow',
		'setCurrentRow',
		'isCheckedByRadioRow',
		'setRadioRow',
		'clearCurrentRow',
		'clearRadioRow',
		'getCurrentRecord',
		'getRadioRecord',
		'getCurrentColumn',
		'setCurrentColumn',
		'clearCurrentColumn',
		'sort',
		'clearSort',
		'isSort',
		'getSortColumns',
		'closeFilter',
		'isFilter',
		'isRowExpandLoaded',
		'clearRowExpandLoaded',
		'reloadRowExpand',
		'toggleRowExpand',
		'setAllRowExpand',
		'setRowExpand',
		'isExpandByRow',
		'clearRowExpand',
		'clearRowExpandReserve',
		'getRowExpandRecords',
		'getTreeExpandRecords',
		'isTreeExpandLoaded',
		'clearTreeExpandLoaded',
		'reloadTreeExpand',
		'reloadTreeChilds',
		'toggleTreeExpand',
		'setAllTreeExpand',
		'setTreeExpand',
		'isTreeExpandByRow',
		'clearTreeExpand',
		'clearTreeExpandReserve',
		'getScroll',
		'scrollTo',
		'scrollToRow',
		'scrollToColumn',
		'clearScroll',
		'updateFooter',
		'updateStatus',
		'setMergeCells',
		'removeInsertRow',
		'removeMergeCells',
		'getMergeCells',
		'clearMergeCells',
		'setMergeFooterItems',
		'removeMergeFooterItems',
		'getMergeFooterItems',
		'clearMergeFooterItems',
		'openTooltip',
		'focus',
		'blur',
		'connect',
		'dispatchEvent',
		'commitProxy',
		'zoom',
		'isMaximized',
		'maximize',
		'revert',
		'getFormItems',
		'getPendingRecords',
		'getProxyInfo',
		'extendTableMethods',
		'callSlot',
		'getExcludeHeight',
		'getParentHeight',
		'triggerToolbarBtnEvent',
		'triggerToolbarTolEvent',
		'triggerZoomEvent',
		'setFilter',
		'clearFilter',
		'getCheckedFilters',
		'closeMenu',
		'insert',
		'insertAt',
		'remove',
		'removeCheckboxRow',
		'removeRadioRow',
		'removeCurrentRow',
		'getRecordset',
		'getInsertRecords',
		'getRemoveRecords',
		'getUpdateRecords',
		'getActiveRecord',
		'getSelectedCell',
		'clearActived',
		'clearSelected',
		'isActiveByRow',
		'setActiveRow',
		'setActiveCell',
		'setSelectCell',
		// 'exportData',
		'importByFile',
		'importData',
		'saveFile',
		'readFile',
		'print',
		'openImport',
		'openExport',
		'openPrint',
		'fullValidate',
		'validate',
		'clearValidate',
		'renderVN',
	];
	const extendTableMethods = <T>(methodKeys: T[]) => {
		const funcs: any = {};
		methodKeys.forEach((name: any) => {
			funcs[name] = (...args: any[]) => {
				const $xetable: any = zhGrid.value;
				return $xetable && $xetable[name](...args);
			};
		});
		return funcs;
	};
	return extendTableMethods(functionList);
}
